package com.naiterui.ehp.bs.recommend.controller.inner;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.recommend.exception.ExceptionCodes;
import com.naiterui.ehp.bs.recommend.service.IRecomAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;
/**
 * @author guoyongxiang
 * @date 2019/12/9 19:50
 * @since 1.0.0
 */
@Slf4j
@RequestMapping("recommend/inner/task")
@RestController
public class InnerTaskController {

  @Autowired
  private IRecomAuditService recomAuditService;

  @RequestMapping("assign/audit/recom")
  public ResponseVO<Void> assignAuditRecom() throws BusinessException {
	log.info("执行处方分配/重分逻辑！");
    recomAuditService.assignAuditPharmacis();
    return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
  }

  /**
   * 定时扫描超时未审核处方 时间间隔：10秒钟
   *
   * @return
   * @throws BusinessException
   */
  @RequestMapping("expired/recom")
  public ResponseVO<Void> expiredRecom() throws BusinessException {
    log.info("定时扫描超时未审核处方");
    recomAuditService.updateExpired();
    return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
  }

  /**
   * 每天两个时段「11:30」及「17:30」给管理员发送统计短信，统计截至当前时间有多少条待审核处方。
   *
   * @return
   * @throws BusinessException
   */
  @RequestMapping("summary/pending/recom")
  public ResponseVO<Void> summaryPendingRecom() throws BusinessException {
    log.info("给管理员发送统计短信");
    recomAuditService.summaryPendingRecom();
    return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
  }

}
